/**
 * @author zhuzhaofeng
 * @description Listener Memory
 */
export default (time, callback) => {
    setInterval(() => {
        let size = performance.memory;
        let result = {
            type: 'memory',
            info: [
                {
                    name: 'usedJSHeapSize',
                    key: '已使用的内容',
                    value: (size.usedJSHeapSize / 1048576).toFixed(2)
                }, {
                    name: 'totalJSHeapSize',
                    key: '可使用的内容',
                    varlue: (size.totalJSHeapSize / 1048576).toFixed(2)
                }, {
                    name: 'jsHeapSizeLimit',
                    key: '可使用内存大小限制的内容',
                    value: (size.jsHeapSizeLimit / 1048576).toFixed()
                }, {
                    name: 'state',
                    key: "状态",
                    value: size.usedJSHeapSize > size.totalJSHeapSize ? "可能出现内存泄漏" : "正常"
                }
            ]
        }
        callback(result);
    }, time)
}